package com.gzsxy.lesson01;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.ZonedDateTime;

//测试IP
public class TestInetAddress {
    public static void main(String[] args) {
//        try {
//            InetAddress byName = InetAddress.getByName("127.0.0.1");
//            //查询网站IP
//            InetAddress byName1 = InetAddress.getByName("www.baidu.com");
//            InetAddress byName2 = InetAddress.getByName("localhost");
//           //查询本机内网IP
//            InetAddress localHost = InetAddress.getLocalHost();
//            System.out.println(byName);
//            System.out.println(byName1);
//            System.out.println(byName2);
//            System.out.println(localHost);
//
//
//            //常用方法
//            System.out.println(byName.getAddress()); //地址
//            System.out.println(byName.getCanonicalHostName());//规范名字 ip
//            System.out.println(byName.getHostAddress()); //ip
//            System.out.println(byName.getHostName()); //域名


//        } catch (UnknownHostException e) {
//            e.printStackTrace();
//        }

        ZonedDateTime now = ZonedDateTime.now();
        System.out.println(now);

    }
}
